<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>商品详情</title>
	<link rel="stylesheet" href="__INDEX__/css/mui.min.css">
    <link rel="stylesheet" href="__INDEX__/css/style.css" />
    <link rel="stylesheet" href="__INDEX__/css/mall.css" />
</head>
<body>

	<nav class="mui-bar mui-bar-tab sppage_tab">
	    <a class="mui-tab-item kefu">
	        <span class="mui-icon"></span>
	        <span class="mui-tab-label">客服</span>
	    </a>
	    <a class="mui-tab-item dianpu" onclick="click_t()">
	        <span class="mui-icon"></span>
	        <span class="mui-tab-label">店铺</span>
	    </a>
	    <a class="mui-tab-item gouwuche" id='add_cart'>
	        <span class="mui-tab-label">加入购物车</span>
	    </a>
	    <a class="mui-tab-item lijigoumai" id='buy'>
	        <span class="mui-tab-label" >立即购买</span>
	    </a>
	</nav>
	<div class="mui-content">
	    <div class="cp_pimgbox">
	    			<div id="slider" class="mui-slider sj_slider">
					<div class="mui-slider-group mui-slider-loop">
						<div class="mui-slider-item">
							<a href="#">
								<img src="{$good_info.thumb}">
							</a>
						</div>
						<!-- 额外增加的一个节点(循环轮播：第一个节点是最后一张轮播) -->
						<div class="mui-slider-item mui-slider-item-duplicate">
							<a href="#">
								<img src="{$good_info.thumb}">
							</a>
						</div>
					</div>
					<div class="mui-slider-indicator">
						<div class="mui-indicator mui-active"></div>
						<div class="mui-indicator"></div>
						<div class="mui-indicator"></div>
					</div>
				</div>
	   
	    	
	    </div>
	    <div class="cpp_nambox">
	    	<div class="cpp_nam clearfix">
		    	<div class="left">
		    		<p class="name">{$good_info.goods_name}</p>
		    		<p class="pri"><em style="font-size: 12px;">零售价：</em>¥{$good_info.sale_price}&nbsp;&nbsp;&nbsp;&nbsp;<em style="font-size: 12px;">会员价：</em>¥{$good_info.sale_price2}</p>
		    	</div>
		    	<div class="right" onclick="show_fx()">
		    		<p class="fenximg"><img src="__INDEX__/images/fenxiang.png"></p>
		    		<p >分享</p>
		    	</div>
	    	</div>
	    	<div class="ccp_tips">
	    		<span>运费：包邮</span>
	    		<span>库存：{$good_info.store}</span>
	    	</div>
	    </div>
	    <div class="cpp_conbox">{$good_info.content|html_entity_decode}</div>
	</div>
	<div id="sp_tc" style="display: none;">
		<nav class="mui-bar mui-bar-tab sppage_tab">
	    <a class="mui-tab-item lijigoumai" id='next'>
	        <span class="mui-tab-label">下一步</span>
	    </a>
		</nav>
		<div class="mask"></div>
		<div class="fuk_bdsj">
			<div class="cpqr_topbox">
				<div class="cpqr_img"><img src="__INDEX__/images/banner.jpg"></div>
				<div class="cpqr_nambox">
					<p class="name">{$good_info.goods_name}</p>
					<p class="pri">¥{$good_info.price}</p>
				</div>
				<a href="#" class="close" id='my_close'><img src="__INDEX__/images/close.png"></a>
			</div>
			<div class="cpqr_numbox">
				<div class="left">数量</div>
				<div class="right">
					<span>库存：{$good_info.store}</span>
					<div class="mui-numbox" data-numbox-min='1' data-numbox-max='{$good_info.store}'>
						<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
						<input class="mui-input-numbox" type="number" id='goods_num'/>
						<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
					</div>
				</div>
				
			</div>
		</div>
	</div>
	<input id="add_type" type="hidden" value="1">
	<div class="share-tip" id="share-tip" style="display: none;">
		<img src="/public/static/images/share.png">
		<a class="a-know" id="clostShare-tip" href="javascript:$('#share-tip').hide()">我知道了</a>
</div>
</body>
<script src="__INDEX__/js/mui.min.js"></script>
  {include file="public/footer" /}
</html>
   <script>
	var gallery = mui('.mui-slider');
	gallery.slider({
		interval: 3000 //自动轮播周期，若为0则不自动播放，默认为0；
	});
	
	
	var buy = document.getElementById("buy");
	//监听点击事件
	buy.addEventListener("tap",function () {
		var id="{$Think.session.user_info.id}";
		if(id==null||id==""||id==undefined){
			layer.msg('请您先注册！',{time:2*1000},function() {
				window.location.href="{:url('member/regist')}";
			})
		}
	  	$("#add_type").val(2);
		$("#sp_tc").show();
	});

	var add_cart = document.getElementById("add_cart");
	//监听点击事件
	add_cart.addEventListener("tap",function () {
		var id="{$Think.session.user_info.id}";
		if(id==null||id==""||id==undefined){
			layer.msg('请先注册会员！',{time:2*1000},function() {
				window.location.href="{:url('member/regist')}";
			})
		}
	  	$("#add_type").val(1);
		$("#sp_tc").show();
	});

	var next = document.getElementById("next");
	//监听点击事件
	next.addEventListener("tap",function () {
	  	var add_type = $("#add_type").val();
		if(add_type == 1){	//购物车
			add_car();
		}else{	//订单
			add_order();
		}
	});
	var my_close = document.getElementById("my_close");
	//监听点击事件
	my_close.addEventListener("tap",function () {
  	$("#sp_tc").hide();
	});


	
	function show_fx(){
		$('#share-tip').show();
	}
	
	function add_car(){
		$.ajax({
			type:"post",
			url: "{:url('index/add_car')}",
			data: {
					goods_id	:	"{$good_info.id}",
					goods_num	:	$("#goods_num").val()
			},
			success: function(data) {
				if(data.code == 200) {
					location.href = data.url
				}else{
					layer.msg(data.msg);
				}
			}
		})
	}
	
	function add_order(){
		$.ajax({
			type:"post",
			url: "{:url('index/add_goods_order')}",
			data: {
					goods_id	:	"{$good_info.id}",
					goods_num	:	$("#goods_num").val()
			},
			success: function(data) {
				if(data.code == 200) {
					location.href = data.url
				}else{
					layer.msg(data.msg);
				}
			}
		})
	}
	
	function click_t(){
		window.location.href = "index";
	}
</script>
